package com.cjf.weather.weatherdata.controller;

import com.cjf.weather.weatherdata.service.WeatherDataService;
import com.cjf.weather.weatherdata.vo.WeatherResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @author cjf
 * @description 天气预报控制器
 * @create 2019-03-26 17:46
 */
@RestController
@RequestMapping("/weather")
public class WeatherController {

    @Autowired
    private WeatherDataService weatherDataService;

    @GetMapping("/cityId/{cityId}")
    public WeatherResponse getWeatherByCityId(@PathVariable("cityId") String cityId) {
        WeatherResponse weatherResponse = weatherDataService.getDataByCityId(cityId);
        return weatherResponse;
    }

    @GetMapping("/cityName/{cityName}")
    public WeatherResponse getWeatherByCityName(@PathVariable("cityName") String cityName) {
        WeatherResponse weatherResponse = weatherDataService.getDataByCityName(cityName);
        return weatherResponse;
    }
}
